package cn.shengchao.examstar.knowledge.infrastructure.converter;

import cn.shengchao.examstar.knowledge.domain.entity.KnowledgePointMastery;
import cn.shengchao.examstar.knowledge.infrastructure.dao.po.TKnowledgePointMastery;
import org.springframework.stereotype.Component;

/**
 * 知识点掌握度实体转换器
 */
@Component
public class KnowledgePointMasteryConverter {

    /**
     * PO转领域实体
     */
    public KnowledgePointMastery toEntity(TKnowledgePointMastery po) {
        if (po == null) {
            return null;
        }
        
        return KnowledgePointMastery.builder()
                .id(po.getId())
                .userId(po.getUserId())
                .knowledgePointId(po.getKnowledgePointId())
                .degreeOfMastery(po.getDegreeOfMastery())
                .accuracyRate(po.getAccuracyRate())
                .studyPlanId(po.getStudyPlanId())
                .status(po.getStatus())
                .build();
    }
    
    /**
     * 领域实体转PO
     */
    public TKnowledgePointMastery toPO(KnowledgePointMastery entity) {
        if (entity == null) {
            return null;
        }
        
        TKnowledgePointMastery po = new TKnowledgePointMastery();
        po.setId(entity.getId());
        po.setUserId(entity.getUserId());
        po.setKnowledgePointId(entity.getKnowledgePointId());
        po.setDegreeOfMastery(entity.getDegreeOfMastery());
        po.setAccuracyRate(entity.getAccuracyRate());
        po.setStudyPlanId(entity.getStudyPlanId());
        po.setStatus(entity.getStatus());
        
        return po;
    }
} 